<?php
//Zend Framework 的默认路由规则是 http://域名/控制器名/动作（方法）名
require_once('application/include/config_ini.php');
require_once('application/include/global.php');
require_once('application/include/functions.php');
require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();//自动载入zend类文件,调用Zend_Loader类的registerAutoload()成员函数
$registry = Zend_Registry::getInstance();
//设置模板显示路径,视图组件
$view=new Zend_View();
$config_ini=new Zend_Config_Ini(APP_DIR.'/include/config.ini',null,true);
$view->setScriptPath(APP_DIR.'/views/scripts/default/index/');
$registry['view']=$view;//注册view
Zend_Session::start();//开启session
$registry->set('config_ini',$config_ini);//注册配置信息,添加进注册表,也可以Zend_Registry::set('config',$config);
$registry->set('version',$config_ini->site->st->version);
$registry->set('domain',$config_ini->site->st->domain);
$registry->set('keyword',$config_ini->site->st->keyword);
$registry->set('sitename',$config_ini->site->st->sitename);
$registry->set('footword',$config_ini->site->st->footword);
$registry->set('record',$config_ini->site->st->record);
$db = Zend_Db::factory($config_ini->general->db->adapter,$config_ini->general->db->toArray());//使用数据库
Zend_Db_Table::setDefaultAdapter($db);
$db->query("SET NAMES {$config_ini->general->db->charset}");
$registry->set('db',$db);
//设置控制器
$frontController = Zend_Controller_Front::getInstance();//实例化前端控制器
$frontController -> setBaseUrl('/');//设置基本路径
$frontController -> setParam('noViewRenderer',true);
$frontController -> setParam('noErrorHandler',false);//禁用noerrorhandler插件
$frontController -> registerPlugin(new Zend_Controller_Plugin_ErrorHandler());//注册错误处理插件,出错自动转向error
$frontController -> setControllerDirectory(array(
												'default' => APP_DIR.'/modules/default/controllers',
												'admin'   => APP_DIR.'/modules/admin/controllers'
												));
$frontController->throwExceptions(DEBUGS);//设置发现不异常抛出。启用404页面
//Zend_Layout::startMvc(array('layoutPath'=>APP_DIR.'/layouts'));//启用Zend_Layout,布局显示脚本
//运行
$frontController->dispatch();
?>